import { Injectable, NestMiddleware, Request, Response } from '@nestjs/common';

@Injectable()
export class LoginMiddleware implements NestMiddleware {
  use(req: Request, res: Response, next: () => void) {
    const { token } = req.headers as any
    if (token) {
      next();
    } else {
      (res as any).send('请先登录')
      return;
    }
  }
}
